class Solution {
    public int getMaxLen(int[] nums) {
        int len = nums.length ;
        int[] f = new int[len+1] ;
        int[] g = new int[len+1] ;
        int max = -Integer.MAX_VALUE ;
        for(int i=1 ; i <= len ; i ++){
            int a = f[i-1] , b = g[i-1] , x = nums[i-1];
            if(x > 0){
                f[i] = f[i-1]+1 ;
                g[i] = g[i-1]==0?0:g[i-1]+1;
            }
            if(x < 0){
                f[i] = g[i-1]==0?0:g[i-1]+1 ;
                g[i] = f[i-1]+1;
            }
            max = Math.max(f[i] , max) ;
        }
        return max ;
    }
}